<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../js/vue.js">
    </script>
</head>
<body>

<!--准备容器-->
<div id="root">
    <h2>人员列表</h2>
    <button @click="updateMDM">更新马冬梅信息</button>
    <ul>
        <li v-for="(p,index) in persons" :key="index">
            {{p.name}}-{{p.age}}-{{p.sex}}
        </li>
    </ul>

</div>

<script type="text/javascript">
    Vue.config.productionTip = false;

    const  vm = new Vue({
        el: '#root',
        data: {
            sortType:0,//0代表原顺序，1代表降序，2代表升序
            keyWord: '',
            persons: [
                {id: '001', name: '马冬梅', age: 30, sex: '女'},
                {id: '002', name: '周冬雨', age: 25, sex: '女'},
                {id: '003', name: '周杰伦', age: 18, sex: '男'},
                {id: '004', name: '温兆伦', age: 52, sex: '男'}
            ],
        },
        methods:{
            updateMDM(){
                
                // this.persons[0].name = '马保国' //奏效
                // this.persons[0].age = 50 //奏效
                // this.persons[0].sex = '男' //奏效
                // 不奏效
                this.persons[0] = {id: '001', name: '马保国', age: 50, sex: '男'}
            }
        }
    })
</script>
</body>
</html>